-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from andygout/handle-node-module-duplicate-fi…
…lename-import-resolution Handle node module duplicate filename import resolution
- Loading branch information
Showing
11 changed files
with
131 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.importable { | ||
color: red; | ||
} | ||
|
||
.rollup .plugin .scss { | ||
color: green; | ||
user-select: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('scss imported from native files and node_modules'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import './input.scss' | ||
|
||
console.log('scss imported from native files and node_modules') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@import 'import-resolution-test/main'; | ||
|
||
.rollup { | ||
.plugin { | ||
.scss { | ||
color: green; | ||
user-select: none; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// A .js file with the same name as the intended .scss file to be imported. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.importable { | ||
color: red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import scss from '../../index.es.js' | ||
|
||
export default { | ||
input: './input.js', | ||
output: { | ||
file: 'output.js', | ||
format: 'esm' | ||
}, | ||
plugins: [scss({ fileName: 'output.css' })] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const fs = require('node:fs'); | ||
const path = require('node:path'); | ||
|
||
const NODE_MODULES_MOCK_PACKAGE_PATH = path.join(__dirname, '../../node_modules/import-resolution-test'); | ||
const CURRENT_DIRECTORY_PATH = path.join(__dirname, '.'); | ||
|
||
const IMPORTABLE_FILE_NAME = 'main'; | ||
const IMPORTABLE_JS_FILE_NAME = `${IMPORTABLE_FILE_NAME}.js`; | ||
const IMPORTABLE_SCSS_FILE_NAME = `${IMPORTABLE_FILE_NAME}.scss`; | ||
|
||
/* If one does not already exist, | ||
* create a path to the node_modules mock package. */ | ||
if (!fs.existsSync(NODE_MODULES_MOCK_PACKAGE_PATH)) { | ||
fs.mkdirSync(NODE_MODULES_MOCK_PACKAGE_PATH); | ||
} | ||
|
||
/* Copy the specified file with the .js extension | ||
* to the node_modules mock package. */ | ||
fs.copyFile( | ||
`${CURRENT_DIRECTORY_PATH}/${IMPORTABLE_JS_FILE_NAME}`, | ||
`${NODE_MODULES_MOCK_PACKAGE_PATH}/${IMPORTABLE_JS_FILE_NAME}`, | ||
error => { | ||
if (error) { | ||
console.log(error); | ||
} | ||
} | ||
) | ||
|
||
/* Copy the specified file with the .scss extension | ||
* to the node_modules mock package. */ | ||
fs.copyFile( | ||
`${CURRENT_DIRECTORY_PATH}/${IMPORTABLE_SCSS_FILE_NAME}`, | ||
`${NODE_MODULES_MOCK_PACKAGE_PATH}/${IMPORTABLE_SCSS_FILE_NAME}`, | ||
error => { | ||
if (error) { | ||
console.log(error); | ||
} | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const fs = require('node:fs'); | ||
const path = require('node:path'); | ||
|
||
const NODE_MODULES_MOCK_PACKAGE_PATH = path.join(__dirname, '../../node_modules/import-resolution-test'); | ||
|
||
/* Now that it has served its purpose, | ||
* remove the node_modules mock package. */ | ||
fs.rm( | ||
NODE_MODULES_MOCK_PACKAGE_PATH, | ||
{ recursive: true, force: true }, | ||
error => { | ||
if (error) { | ||
throw error; | ||
} | ||
} | ||
); |