Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eighty-trees-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ice/pkg': major
---

feat: change polyfill default to none [BREAK]
1 change: 0 additions & 1 deletion packages/pkg/src/core/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const defaultBundleUserConfig: BundleUserConfig = {
js: defaultMinifyFunction,
css: defaultMinifyFunction,
},
polyfill: 'usage',
compileDependencies: false,
};

Expand Down
8 changes: 7 additions & 1 deletion packages/pkg/src/rollupPlugins/swc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async function transformImport(source: string, sourceFilename: string) {
}
if (targetImport.n.startsWith('@swc/helpers')) {
if (!isESM) {
// Replace @swc/helpers with cjs path.
// Replace @swc/helpers with cjs
const importStr = source.substring(targetImport.ss, targetImport.se);
// Import rule: import { _ as _type_of } from "@swc/helpers/_/_type_of";
const matchImport = importStr.match(/import\s+{\s+([\w*\s{},]*)\s+}\s+from\s+['"](.*)['"]/);
Expand All @@ -107,6 +107,12 @@ async function transformImport(source: string, sourceFilename: string) {
str().overwrite(targetImport.ss, targetImport.se, replaceModule);
}
}
} else if (targetImport.n.startsWith('core-js')) {
// Replace core-js with cjs
if (!isESM) {
const replaceRequire = `require('${targetImport.n}')`;
str().overwrite(targetImport.ss, targetImport.se, replaceRequire);
}
}
});

Expand Down
6 changes: 2 additions & 4 deletions packages/pkg/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,8 @@ export interface BundleUserConfig {
};

/**
* Weather or not add the polyfill to the code.
* @default ['usage']
*
* In the next version(v2), the value of polyfill will be `false`.
* Weather or not add the polyfill(core-js) to the code.
* `undefined` is equivalent to `false`
*/
polyfill?: false | 'entry' | 'usage';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ describe('initTask', () => {
});

describe.each<[key: keyof BundleUserConfig, defaultValue: any, validValues: any[]]>([
['polyfill', 'usage', [false, 'usage', 'entry']],
['polyfill', undefined, [false, 'usage', 'entry']],
['compileDependencies', false, [false, true, ['react']]],
['externals', undefined, [false, { react: 'React' }]],
['browser', undefined, [false, true]],
Expand Down
Loading